/**
 * 任务分组
 */

$(function(){
	webUtils.nameSpace("wiseMen.scheduler.taskGroup");
	
	wiseMen.scheduler.taskGroup.add=function(grid){
		var uuid=webUtils.uuid();
		var d=webUtils.dialog({
			url:ctx+"/dataModelDefAct/editTpl.do?dms=JOB_TASK_GROUP&winId="+uuid,
			onremove:function(){
				webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
			}
		});
		webUtils.topicSubscribe("dialog.submit.success."+uuid,function(data){
			grid.bootstrapTable("refresh");
			d.close();
		},true);
	}
	
	wiseMen.scheduler.taskGroup.mod=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		var uuid=webUtils.uuid();
		var d=webUtils.dialog({
			url:ctx+"/dataModelDefAct/editTpl.do?dms=JOB_TASK_GROUP&JOB_TASK_GROUP_ID="+row.ID+"&winId="+uuid,
			onremove:function(){
				webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
			}
		});
		webUtils.topicSubscribe("dialog.submit.success."+uuid,function(data){
			grid.bootstrapTable("refresh");
			d.close();
		},true);
	}
	
	wiseMen.scheduler.taskGroup.del=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		webUtils.confirm("删除数据将不可恢复，是否继续！",function(r){
			if(r){
				$.post(ctx + "/formDataAction/delByIds.do", {tableName:"JOB_TASK_GROUP",ids: row.ID}, function (data) {
	                if (data.success) {
	                	grid.bootstrapTable("refresh");
	                } else {
	                	webUtils.error(data.msg);
	                }
	            }, 'json');
			}
		});
	}
	
	wiseMen.scheduler.taskGroup.view=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		var uuid=webUtils.uuid();
		var d=webUtils.dialog({
			url:ctx+"/dataModelDefAct/viewTpl.do?dms=JOB_TASK_GROUP&JOB_TASK_GROUP_ID="+row.ID+"&winId="+uuid,
			onremove:function(){
			}
		});
	}
});